var forumNameExistFlag = false;
var trNodeTag;



function goToFirstPage() {
	$("input[name='targetPage']").val(1);
	goToPage();
}

function goToPreviousPage() {
	var now = $("input[name='nowPage']").val();
	var total = $("input[name='totalPage']").val();
	if (parseInt(now) - 1 >= 1) {
		document.topicDetailsForm.action = "/EKMS-web/forum/visitForum/showTopicDetails.do?action=listReply";
		document.topicDetailsForm.submit();
	} else {
		alert("This is the first page!");
	}
}

function goToPreviousPage() {
	var now = $("input[name='nowPage']").val();
	var total = $("input[name='totalPage']").val();
	if (parseInt(now) - 1 >= 1) {
		document.topicDetailsForm.action = "/EKMS-web/forum/visitForum/showTopicDetails.do?action=goToPreviousPage";
		document.topicDetailsForm.submit();
	} else {
		alert("This is the first page!");
	}
}

function goToNextPage() {
	var now = $("input[name='nowPage']").val();
	var total = $("input[name='totalPage']").val();
	if (parseInt(now) + 1 <= total) {
		document.topicDetailsForm.action = "/EKMS-web/forum/visitForum/showTopicDetails.do?action=goToNextPage";
		document.topicDetailsForm.submit();
	} else {
		alert("This is the last page!");
	}
}

function goToLastPage() {
	var total = $("input[name='totalPage']").val();
	$("input[name='targetPage']").val(total);
	goToPage();
}

function goToPage() {
	var target = $("input[name='targetPage']").val();
	var total = $("input[name='totalPage']").val();
	if (typeof (target) != NaN && parseInt(target) > 0
			&& parseInt(target) <= parseInt(total)) {
		document.topicDetailsForm.action = "/EKMS-web/forum/visitForum/showTopicDetails.do?action=goToTargetPage";
		document.topicDetailsForm.submit();
	} else {
		alert("The page number must be a number and between 0 and " + total
				+ "!");
	}
}

function submitReply(){
	document.topicDetailsForm.action = "/EKMS-web/forum/visitForum/showTopicDetails.do?action=postReply";
	document.topicDetailsForm.submit();
}
